import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: LIUYANJIAO
 * Date: 2024-11-28
 * Time: 13:31
 */
public class slousion1 {
    //直接插入排序
    //交换
    public static void swap(String[]arr,int a,int b){
        String tmp=arr[a];
        arr[a]=arr[b];
        arr[b]=tmp;
    }
    public static void sort(String[] arr,int left,int right){
        if(right>=arr.length) return;
        if(left>=right) return;
        if(arr[left].compareTo(arr[left+1])>0){
            swap(arr,left,left+1);
            sort(arr,0,left);
        }
        left++;
        sort(arr,left,right);
    }

    public static void main(String[] args) {
        String[] arr=new String[]{"计算机导论","数据结构与算法","离散数学","概率论","数字逻辑与计算机组成"};
        sort(arr,0,arr.length-1);
        System.out.println(Arrays.toString(arr));
    }
}
